home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
diskmags
/
3565-4.665
/
dmg-4437
/
packed.12
/
book2
/
book2
Wrap
Text File
|
1987-04-21
|
4KB
|
100 lines
DATABASE TUTORIAL PART 2
BY DEANO
In case you missed last months STOSSER this is a beginners tutorial about
how to write a simple database. For those of you who read last months
part of the tutorial then this month I will show you the next part of it.
This month we are going to create a file.
Note that the main program with the create file routine installed can be
found on this disk. We are just going to look at the routine for creating
a file. First, lets keep the user informed of how many files are in memory
at the moment.
225 locate 0,18 : print "FILES:";FILES
After every routine, the program will come back to this line. This is to
keep the user updated on how many files are held.
Right, everythings set up. Now we just have to wait for the user to select
a function.
230 rem---WAIT FOR AN INPUT
240 K$=input$(1)
250 rem---CHECK WHICH KEY HAS BEEN PRESSED
260 if K$="C" or K$="c" then goto 400
270 if K$="D" or K$="d" then goto 500
280 if K$="F" or K$="f" then goto 600
290 if K$="L" or K$="l" then goto 700
300 if K$="P" or K$="p" then goto 800
310 if K$="Q" or K$="q" then goto 900
320 K$="" : goto 240
The varible K$ is used to store the users selection. At the moment he only
chose C to create a file....the program will then go to line 400 which is
the input routine. Line 320 clears the varible and returns to line 240
ready to await another selection.
400 rem----CREATE A FILE
410 curs on : inc FILES
420 rem---GET SURNAME
430 X=8 : Y=4 : gosub 2000 : SURNAME$(FILES)=K$
440 rem---GET NAME
450 X=5 : Y=6 : gosub 2000 : NAME$(FILES)=K$
460 rem---GET ADDRESS
470 X=8 : Y=8 : gosub 2000 : ADDR$(FILES)=K$
480 rem---GET TOWNS
490 X=6 : Y=10 : gosub 2000 : T0WN$(FILES)=K$
500 rem---GET POSTCODE
510 X=9 : Y=12 : gosub 2000 : POST$(FILES)=K$
520 rem---GET PHONE NUMBER
530 X=6 : Y=14 : gosub 2000 : PHONE$(FILES)=K$
540 rem---GET INFO
550 X=5 : Y=16 : gosub 2000 : INFO$(FILES)=K$
555 rem---FILE CREATED SO GO BACK AND WAIT FOR NEXT INPUT
560 K$="" : curs off : gosub 2070 : goto 225
This is a kind of set up to enter the information needed. The X and Y
variables hold the X and Y co-ordinates of the text cursor. Notice at the
start of this part we turns the cursor on and add one to the FILES
variable. This is the number of the file we are currently creating.
The x and y variables are needed to postion the text cursor just after
each field name...ie SURNAME, NAME, etc... The routine then does a
subroutine to the routine that actually enters the info into a variable.
Once the file has been created the program turns off the cursor, does a
subroutine to clear the wording entered off the screen then goes back to
wait for another selection from the user.
2000 rem---INPUT ROUTINE
2010 locate X,Y
2020 input "";K$
2030 if K$="" then K$="UNKNOWN"
2040 return
The actual input routine. Note how we use the locate command to postion
the cursor at the right place for every field name. Line 2020 allows you
to type in the information while line 2030 checks if the users just
pressed enter without typing anything in.
2070 rem---CLEAR INFO OFF SCREEN
2080 wait 30
2090 locate 8,4 : print space$(50)
2100 locate 5,6 : print space$(53)
2110 locate 8,8 : print space$(50)
2120 locate 6,10 : print space$(52)
2130 locate 9,12 : print space$(49)
2140 locate 6,14 : print space$(52)
2150 locate 5,16 : print space$(53)
2160 return
The final part which clears the wording off the screen once the file is
created. The space$ command just prints a line of spaces to clear it.
Well thats it for this month. Feel free to play around with the routine
on disk. Next month we'll add a delete file function.
This is Deano signing off